﻿using System;
using Oxage.CNC.Models;

namespace Oxage.Simulator
{
	[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
	public sealed class InlineBindingAttribute : Attribute
	{
		public InlineBindingAttribute(Type inlineType)
		{
			TestInlineType(inlineType);
			this.InlineType = inlineType;
		}

		public Type InlineType
		{
			get;
			set;
		}

		public int Priority
		{
			get;
			set;
		}

		internal void TestInlineType(Type inlineType)
		{
			//Test if type implements the interface
			if (!typeof(IMachineCodeInline).IsAssignableFrom(inlineType))
			{
				throw new ArgumentException("Type does not implement IMachineCodeInline interface!", "inlineType");
			}
		}
	}
}
